Imports System.Data.SqlClient
Public Class cls_isometrico_

    Implements ICloneable

#Region "Variables ..."
    Private int_idisometrico As Integer = 0
    Private str_codigo As String = ""
    Private str_nombre As String = ""
    Private int_hoja As Integer = 0
    Private int_hojatotal As Integer = 0
    Private int_idplano As Integer = 0
    Private int_idarea As Integer = 0
    Private int_idskid As Integer = 0
    Private int_idlineaadicional1 As Integer = 0
    Private str_lineaadicional1 As String = ""
    Private int_idlineaadicional2 As Integer = 0
    Private str_lineaadicional2 As String = ""
    Private int_idproveedor As Integer = 0
    Private dbl_kiloscampo As Double = 0
    Private dbl_kilostaller As Double = 0
    Private str_observaciones As String = ""
    Private int_idregistro As Integer = 0
    Private int_idobra As Integer = 0
    Private int_idlinea As Integer = 0

    Private obj_registro As cls_registro_ = Nothing
    Private obj_plano As cls_plano_ = Nothing
    Private obj_area As cls_area_ = Nothing
    Private obj_skid As cls_skid_ = Nothing
    Private obj_proveedor As cls_proveedor_ = Nothing
    Private obj_lineaopcional1 As cls_linea_ = Nothing
    Private obj_lineaopcional2 As cls_linea_ = Nothing

    Private col_Items As Collections.Generic.List(Of cls_isometrico_) = Nothing

    Public Overrides Function ToString() As String
        Return nombre
    End Function
#End Region

#Region "Propiedades ..."
    ReadOnly Property This
        Get
            Return Me
        End Get
    End Property
    ReadOnly Property ThisDescripcion As String
        Get
            Return Me.ToString
        End Get
    End Property
    ReadOnly Property pKey
        Get
            Return idisometrico
        End Get
    End Property
    Property idisometrico() As Integer
        Get
            idisometrico = int_idisometrico
        End Get
        Set(ByVal value As Integer)
            int_idisometrico = value
        End Set
    End Property
    Property codigo() As String
        Get
            codigo = str_codigo
        End Get
        Set(ByVal value As String)
            str_codigo = value
        End Set
    End Property
    Property nombre() As String
        Get
            nombre = str_nombre
        End Get
        Set(ByVal value As String)
            str_nombre = value
        End Set
    End Property
    Property hoja() As Integer
        Get
            hoja = int_hoja
        End Get
        Set(ByVal value As Integer)
            int_hoja = value
        End Set
    End Property
    Property hojatotal() As Integer
        Get
            hojatotal = int_hojatotal
        End Get
        Set(ByVal value As Integer)
            int_hojatotal = value
        End Set
    End Property
    Property idplano() As Integer
        Get
            idplano = int_idplano
        End Get
        Set(ByVal value As Integer)
            int_idplano = value
        End Set
    End Property
    Property idarea() As Integer
        Get
            idarea = int_idarea
        End Get
        Set(ByVal value As Integer)
            int_idarea = value
        End Set
    End Property
    Property idskid() As Integer
        Get
            idskid = int_idskid
        End Get
        Set(ByVal value As Integer)
            int_idskid = value
        End Set
    End Property
    Property idlineaadicional1() As Integer
        Get
            idlineaadicional1 = int_idlineaadicional1
        End Get
        Set(ByVal value As Integer)
            int_idlineaadicional1 = value
        End Set
    End Property
    Property lineaadicional1() As String
        Get
            lineaadicional1 = str_lineaadicional1
        End Get
        Set(ByVal value As String)
            str_lineaadicional1 = value
        End Set
    End Property
    Property idlineaadicional2() As Integer
        Get
            idlineaadicional2 = int_idlineaadicional2
        End Get
        Set(ByVal value As Integer)
            int_idlineaadicional2 = value
        End Set
    End Property
    Property lineaadicional2() As String
        Get
            lineaadicional2 = str_lineaadicional2
        End Get
        Set(ByVal value As String)
            str_lineaadicional2 = value
        End Set
    End Property
    Property idproveedor() As Integer
        Get
            idproveedor = int_idproveedor
        End Get
        Set(ByVal value As Integer)
            int_idproveedor = value
        End Set
    End Property
    Property kiloscampo() As Double
        Get
            kiloscampo = dbl_kiloscampo
        End Get
        Set(ByVal value As Double)
            dbl_kiloscampo = value
        End Set
    End Property
    Property kilostaller() As Double
        Get
            kilostaller = dbl_kilostaller
        End Get
        Set(ByVal value As Double)
            dbl_kilostaller = value
        End Set
    End Property
    Property observaciones() As String
        Get
            observaciones = str_observaciones
        End Get
        Set(ByVal value As String)
            str_observaciones = value
        End Set
    End Property
    Property idregistro() As Integer
        Get
            idregistro = int_idregistro
        End Get
        Set(ByVal value As Integer)
            int_idregistro = value
        End Set
    End Property
    Property idobra As Integer
        Get
            idobra = int_idobra
        End Get
        Set(ByVal value As Integer)
            int_idobra = value
        End Set
    End Property
    Property idlinea As Integer
        Get
            idlinea = int_idlinea
        End Get
        Set(ByVal value As Integer)
            int_idlinea = value
        End Set
    End Property

    Property Items() As Collections.Generic.List(Of cls_isometrico_)
        Get
            Items = col_Items
        End Get
        Set(ByVal value As Collections.Generic.List(Of cls_isometrico_))
            col_Items = value
        End Set
    End Property
    Property plano() As cls_plano_
        Get
            If IsNothing(obj_plano) Then
                obj_plano = New cls_plano_
                If Not obj_plano.Buscar(idplano) Then
                    obj_plano = Nothing
                End If
            End If
            plano = obj_plano
        End Get
        Set(ByVal value As cls_plano_)
            obj_plano = value
        End Set
    End Property
    Property area() As cls_area_
        Get
            If IsNothing(obj_area) Then
                obj_area = New cls_area_
                If Not obj_area.Buscar(idarea) Then
                    obj_area = Nothing
                End If
            End If
            area = obj_area
        End Get
        Set(ByVal value As cls_area_)
            obj_area = value
        End Set
    End Property
    Property skid() As cls_skid_
        Get
            If IsNothing(obj_skid) Then
                obj_skid = New cls_skid_
                If Not obj_skid.Buscar(idskid) Then
                    obj_skid = Nothing
                End If
            End If
            skid = obj_skid
        End Get
        Set(ByVal value As cls_skid_)
            obj_skid = value
        End Set
    End Property
    Property proveedor() As cls_proveedor_
        Get
            If IsNothing(obj_proveedor) Then
                obj_proveedor = New cls_proveedor_
                If Not obj_proveedor.Buscar(idproveedor) Then
                    obj_proveedor = Nothing
                End If
            End If
            proveedor = obj_proveedor
        End Get
        Set(ByVal value As cls_proveedor_)
            obj_proveedor = value
        End Set
    End Property
    Property lineaopcional1 As cls_linea_
        Get
            If IsNothing(obj_lineaopcional1) Then
                obj_lineaopcional1 = New cls_linea_
                If Not obj_lineaopcional1.Buscar(idlineaadicional1) Then
                    obj_lineaopcional1 = Nothing
                End If
            End If
            lineaopcional1 = obj_lineaopcional1
        End Get
        Set(ByVal value As cls_linea_)
            obj_lineaopcional1 = value
        End Set
    End Property
    Property lineaopcional2 As cls_linea_
        Get
            If IsNothing(obj_lineaopcional2) Then
                obj_lineaopcional2 = New cls_linea_
                If Not obj_lineaopcional2.Buscar(idlineaadicional2) Then
                    obj_lineaopcional2 = Nothing
                End If
            End If
            lineaopcional2 = obj_lineaopcional2
        End Get
        Set(ByVal value As cls_linea_)
            obj_lineaopcional2 = value
        End Set
    End Property
    Property registro() As cls_registro_
        Get
            If IsNothing(obj_registro) Then
                obj_registro = New cls_registro_
                If Not obj_registro.Buscar(idregistro) Then
                    obj_registro = Nothing
                End If
            End If
            registro = obj_registro
        End Get
        Set(ByVal value As cls_registro_)
            obj_registro = value
        End Set
    End Property
#End Region

    Private Sub CargarColeccion(ByVal obj_Reader As SqlDataReader)
        col_Items = New Collections.Generic.List(Of cls_isometrico_)
        While obj_Reader.Read()
            Dim Elemento As New cls_isometrico_
            Elemento.int_idisometrico = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idisometrico")))

            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo"))) = False Then
                Elemento.str_codigo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("nombre"))) = False Then
                Elemento.str_nombre = (obj_Reader.GetValue(obj_Reader.GetOrdinal("nombre")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("hoja"))) = False Then
                Elemento.int_hoja = (obj_Reader.GetValue(obj_Reader.GetOrdinal("hoja")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("hojatotal"))) = False Then
                Elemento.int_hojatotal = (obj_Reader.GetValue(obj_Reader.GetOrdinal("hojatotal")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idplano"))) = False Then
                Elemento.int_idplano = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idplano")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idarea"))) = False Then
                Elemento.int_idarea = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idarea")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idskid"))) = False Then
                Elemento.int_idskid = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idskid")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional1"))) = False Then
                Elemento.int_idlineaadicional1 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional1")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional1"))) = False Then
                Elemento.str_lineaadicional1 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional1")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional2"))) = False Then
                Elemento.int_idlineaadicional2 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional2")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional2"))) = False Then
                Elemento.str_lineaadicional2 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional2")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor"))) = False Then
                Elemento.int_idproveedor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("kiloscampo"))) = False Then
                Elemento.dbl_kiloscampo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("kiloscampo")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("kilostaller"))) = False Then
                Elemento.dbl_kilostaller = (obj_Reader.GetValue(obj_Reader.GetOrdinal("kilostaller")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("observaciones"))) = False Then
                Elemento.str_observaciones = (obj_Reader.GetValue(obj_Reader.GetOrdinal("observaciones")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro"))) = False Then
                Elemento.int_idregistro = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idobra"))) = False Then
                Elemento.int_idobra = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idobra")))
            End If
            If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlinea"))) = False Then
                Elemento.int_idlinea = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlinea")))
            End If
            col_Items.Add(Elemento)
        End While
    End Sub

    Private Sub CargarVariables(ByVal obj_Reader As SqlDataReader)
        obj_Reader.Read()
        int_idisometrico = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idisometrico")))

        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo"))) = False Then
            str_codigo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("codigo")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("nombre"))) = False Then
            str_nombre = (obj_Reader.GetValue(obj_Reader.GetOrdinal("nombre")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("hoja"))) = False Then
            int_hoja = (obj_Reader.GetValue(obj_Reader.GetOrdinal("hoja")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("hojatotal"))) = False Then
            int_hojatotal = (obj_Reader.GetValue(obj_Reader.GetOrdinal("hojatotal")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idplano"))) = False Then
            int_idplano = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idplano")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idarea"))) = False Then
            int_idarea = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idarea")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idskid"))) = False Then
            int_idskid = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idskid")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional1"))) = False Then
            int_idlineaadicional1 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional1")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional1"))) = False Then
            str_lineaadicional1 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional1")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional2"))) = False Then
            int_idlineaadicional2 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlineaadicional2")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional2"))) = False Then
            str_lineaadicional2 = (obj_Reader.GetValue(obj_Reader.GetOrdinal("lineaadicional2")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor"))) = False Then
            int_idproveedor = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idproveedor")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("kiloscampo"))) = False Then
            dbl_kiloscampo = (obj_Reader.GetValue(obj_Reader.GetOrdinal("kiloscampo")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("kilostaller"))) = False Then
            dbl_kilostaller = (obj_Reader.GetValue(obj_Reader.GetOrdinal("kilostaller")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("observaciones"))) = False Then
            str_observaciones = (obj_Reader.GetValue(obj_Reader.GetOrdinal("observaciones")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro"))) = False Then
            int_idregistro = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idregistro")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idobra"))) = False Then
            int_idobra = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idobra")))
        End If
        If IsDBNull(obj_Reader.GetValue(obj_Reader.GetOrdinal("idlinea"))) = False Then
            int_idlinea = (obj_Reader.GetValue(obj_Reader.GetOrdinal("idlinea")))
        End If
    End Sub

    Public Sub Nuevo(Optional ByVal ObtenerID As Boolean = False)
        Dim obj_Conexion As New cls_Conexion
        Try
            'Creacion de registro----------------------------------------------------
            If IsNothing(obj_registro) Then
                registro = New cls_registro_
                registro.fechacreado = Now
                registro.idusuariocreado = UsuarioLOG.idusuario
                registro.fechamodificado = Now
                registro.idusuariomodificado = UsuarioLOG.idusuario
                registro.idregistroestado = 1
                registro.idusuarioregistroestado = UsuarioLOG.idusuario
                registro.Nuevo(True)
                idregistro = obj_registro.idregistro
            End If
            '------------------------------------------------------------------------
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__Nuevo"
                .Parameters.Add("@codigo", SqlDbType.nvarchar).Value = str_codigo
                .Parameters.Add("@nombre", SqlDbType.nvarchar).Value = str_nombre
                .Parameters.Add("@hoja", SqlDbType.int).Value = int_hoja
                .Parameters.Add("@hojatotal", SqlDbType.int).Value = int_hojatotal
                .Parameters.Add("@idplano", SqlDbType.int).Value = int_idplano
                .Parameters.Add("@idarea", SqlDbType.int).Value = int_idarea
                .Parameters.Add("@idskid", SqlDbType.int).Value = int_idskid
                .Parameters.Add("@idlineaadicional1", SqlDbType.int).Value = int_idlineaadicional1
                .Parameters.Add("@lineaadicional1", SqlDbType.nvarchar).Value = str_lineaadicional1
                .Parameters.Add("@idlineaadicional2", SqlDbType.int).Value = int_idlineaadicional2
                .Parameters.Add("@lineaadicional2", SqlDbType.nvarchar).Value = str_lineaadicional2
                .Parameters.Add("@idproveedor", SqlDbType.int).Value = int_idproveedor
                .Parameters.Add("@kiloscampo", SqlDbType.decimal).Value = dbl_kiloscampo
                .Parameters.Add("@kilostaller", SqlDbType.decimal).Value = dbl_kilostaller
                .Parameters.Add("@observaciones", SqlDbType.nvarchar).Value = str_observaciones
                .Parameters.Add("@idregistro", SqlDbType.Int).Value = int_idregistro
                .Parameters.Add("@idobra", SqlDbType.Int).Value = int_idobra
                .Parameters.Add("@idlinea", SqlDbType.Int).Value = int_idlinea
                .ExecuteNonQuery()
            End With
            If ObtenerID Then
                CargarUltimo()
            End If
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al Crear el registro de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Sub

    Public Sub Modificar()
        Dim obj_Conexion As New cls_Conexion
        Try
            'Modificacion de registro------------------------------------------------
            registro.fechamodificado = Now : registro.idusuariomodificado = UsuarioLOG.idusuario
            registro.Modificar()
            '------------------------------------------------------------------------
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__Modificar"
                .Parameters.Add("@idisometrico", SqlDbType.int).Value = int_idisometrico
                .Parameters.Add("@codigo", SqlDbType.nvarchar).Value = str_codigo
                .Parameters.Add("@nombre", SqlDbType.nvarchar).Value = str_nombre
                .Parameters.Add("@hoja", SqlDbType.int).Value = int_hoja
                .Parameters.Add("@hojatotal", SqlDbType.int).Value = int_hojatotal
                .Parameters.Add("@idplano", SqlDbType.int).Value = int_idplano
                .Parameters.Add("@idarea", SqlDbType.int).Value = int_idarea
                .Parameters.Add("@idskid", SqlDbType.int).Value = int_idskid
                .Parameters.Add("@idlineaadicional1", SqlDbType.int).Value = int_idlineaadicional1
                .Parameters.Add("@lineaadicional1", SqlDbType.nvarchar).Value = str_lineaadicional1
                .Parameters.Add("@idlineaadicional2", SqlDbType.int).Value = int_idlineaadicional2
                .Parameters.Add("@lineaadicional2", SqlDbType.nvarchar).Value = str_lineaadicional2
                .Parameters.Add("@idproveedor", SqlDbType.int).Value = int_idproveedor
                .Parameters.Add("@kiloscampo", SqlDbType.decimal).Value = dbl_kiloscampo
                .Parameters.Add("@kilostaller", SqlDbType.decimal).Value = dbl_kilostaller
                .Parameters.Add("@observaciones", SqlDbType.nvarchar).Value = str_observaciones
                .Parameters.Add("@idregistro", SqlDbType.Int).Value = int_idregistro
                .Parameters.Add("@idobra", SqlDbType.Int).Value = int_idobra
                .Parameters.Add("@idlinea", SqlDbType.Int).Value = int_idlinea
                .ExecuteNonQuery()
            End With
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al Modificar el registro de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Sub

    Public Sub Eliminar(ByVal idisometrico As Integer)
        Dim obj_Conexion As New cls_Conexion
        Try
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__Eliminar"
                .Parameters.Add("@idisometrico", SqlDbType.int).Value = idisometrico
                .ExecuteNonQuery()
            End With
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al Eliminar el registro de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
        End Try
    End Sub

    Public Function Buscar(ByVal idisometrico As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            Buscar = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__Buscar"
                .Parameters.Add("@idisometrico", SqlDbType.int).Value = idisometrico
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarVariables(obj_Reader)
                Buscar = True
            End If
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al Buscar el registro de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Sub CargarUltimo()
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__CargarUltimo"
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarVariables(obj_Reader)
            End If
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al CargarUltimo registro de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Sub

    Public Function CargarTodos() As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarTodos = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__CargarTodos"
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarTodos = True
            End If
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al CargarTodos los registros de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Function CargarXidlinea(ByVal int_idlinea As Integer) As Boolean
        Dim obj_Conexion As New cls_Conexion
        Dim obj_Reader As SqlDataReader
        Try
            CargarXidlinea = False
            obj_Conexion.Conectar()
            With obj_Conexion.obj_SqlCommand
                .CommandType = CommandType.StoredProcedure
                .Connection = obj_Conexion.obj_SqlConnection
                .CommandText = "isometrico__CargarXidlinea"
                .Parameters.Add("@idlinea", SqlDbType.Int).Value = int_idlinea
            End With
            obj_Reader = obj_Conexion.obj_SqlCommand.ExecuteReader
            If obj_Reader.HasRows Then
                CargarColeccion(obj_Reader)
                CargarXidlinea = True
            End If
        Catch ex As SqlClient.SqlException
            MessageBox.Show("Error al CargarXidlinea los registros de isometrico_." & Chr(13) & _
            "Por favor informe del siguiente detalle técnico:" & Chr(13) & _
            "Nro de error: " & ex.ErrorCode & "." & Chr(13) & _
            "Descripción: " & ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            obj_Conexion.Desconectar()
            obj_Conexion = Nothing
            obj_Reader = Nothing
        End Try
    End Function

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj_isometrico_Clon As New cls_isometrico_
        obj_isometrico_Clon.int_idisometrico = Me.int_idisometrico
        obj_isometrico_Clon.str_codigo = Me.str_codigo
        obj_isometrico_Clon.str_nombre = Me.str_nombre
        obj_isometrico_Clon.int_hoja = Me.int_hoja
        obj_isometrico_Clon.int_hojatotal = Me.int_hojatotal
        obj_isometrico_Clon.int_idplano = Me.int_idplano
        obj_isometrico_Clon.int_idarea = Me.int_idarea
        obj_isometrico_Clon.int_idskid = Me.int_idskid
        obj_isometrico_Clon.int_idlineaadicional1 = Me.int_idlineaadicional1
        obj_isometrico_Clon.str_lineaadicional1 = Me.str_lineaadicional1
        obj_isometrico_Clon.int_idlineaadicional2 = Me.int_idlineaadicional2
        obj_isometrico_Clon.str_lineaadicional2 = Me.str_lineaadicional2
        obj_isometrico_Clon.int_idproveedor = Me.int_idproveedor
        obj_isometrico_Clon.dbl_kiloscampo = Me.dbl_kiloscampo
        obj_isometrico_Clon.dbl_kilostaller = Me.dbl_kilostaller
        obj_isometrico_Clon.str_observaciones = Me.str_observaciones
        obj_isometrico_Clon.int_idregistro = Me.int_idregistro
        obj_isometrico_Clon.col_Items = Me.col_Items
        Return obj_isometrico_Clon
    End Function

End Class
